package com.example.shop_2211

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.view.isVisible
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.base.entity.LoginEntity
import com.example.base.mvvm.BaseViewActivity
import com.example.shop_2211.databinding.ActivityWebViewBinding
@Route(path = "/app/WebViewActivity")
class WebViewActivity : BaseViewActivity<ActivityWebViewBinding>() {
    @Autowired
    @JvmField
    var url = ""
    @Autowired
    lateinit var login:LoginEntity
    override fun initView() {
        //val url = intent.extras?.getString("url")//拿到跳转页面传的值
        ARouter.getInstance().inject(this)
        ToastUtils.showLong(login.phone)
        binding.wv.loadUrl(url!!)//加载页面
        binding.wv.webViewClient = WebViewClient()//在App内显示
        val webChromeClient = object:WebChromeClient(){
            //进度条改变监听方法
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if(newProgress==100){
                    binding.pb.isVisible = false
                }else{
                    binding.pb.progress = newProgress
                }
            }
        }
        binding.wv.webChromeClient = webChromeClient

    }

    override fun initData() {
    }

    override fun getLayout(): Int  = R.layout.activity_web_view

}